package com.kws.tool.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.tool.dto.ChatDto;
import com.kws.tool.dto.UserMessageDto;
import com.kws.tool.service.MerchantUserChatService;
import io.swagger.annotations.Api;
import com.kws.tool.vo.UserMessageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author :yxy
 * @date : 2024/11/27
 */
@RestController
@RequestMapping("merchantUserChat")
@Api(value = "聊天记录", tags = "聊天记录")
public class MerchantUserChatController {

    @Autowired
    private MerchantUserChatService merchantUserChatService;

    @GetMapping("/unreadMessage/{type}")
    @ApiOperation("获取对应平台当前用户所有信息")
    public R<List<ChatDto>> unReadMessage(@PathVariable Integer type){
        return R.ok(merchantUserChatService.unreadMessage(type));
    }

    @GetMapping("/readMessage/{sendUser}")
    @ApiOperation("根据发送者id修改当前用户未读信息为已读")
    public R readMessage(@PathVariable Long sendUser){
        return R.ok(merchantUserChatService.readMessage(sendUser));
    }

    @PostMapping("/userMessage")
    @ApiOperation("获取用户消息")
    public R<Page<UserMessageVo>> userMessage(@RequestBody UserMessageDto userMessageDto){
        return R.ok(merchantUserChatService.userMessage(userMessageDto));
    }
//查询调条件： 时间范围、分页，聊天id（聊天室房间id，带id就只返回当前id的聊天记录，此项为可选）， 发送消息的类型（文件、文字，不传则返回全部类型的消息）
}
